<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8" />
    <title>中医体质分类与评价”电子问卷</title>

    <style>
    #para1{text-align:center;color:cornflowerblue;} 
    p.margin{margin:20px 600px;}
    .center {margin: auto;width: 50%;border: 3px solid cornflowerblue;padding: 10px;}
    input[type=text] {width: 50%;  padding: 2px 4px;  margin: 2px 1px;  box-sizing: border-box;  border: 2px solid cornflowerblue;  border-radius: 1px;}
    </style>

</head>
<body>
    <h1 id="para1">中医体质分类与判定自评表（中华中医药学会标准）</h1>
    <p class="margin">
    <label for="fname"></label>
    您的姓名：<input type="text" id="fname" name="fname" /><br />
    <label for="fname"></label>
    您的年龄：<input type="text" id="lname" name="lname" /><br />
    您的性别：<input type="radio" name="gender" value="男" />男
    <input type="radio" name="gender" value="女" />女 <br />  
    </p>
    
    <div class="center">
        <form method="post" action="getresult.php" name="question">
            <?php
            $k=0;
            $questions = file_get_contents("text.json");
            $questionarray = json_decode($questions,true);
            for($i=0;$i<count($questionarray);$i++){
                echo "<div>" .$questionarray[$i]["part"] . "</div>";                
                for($j=0; $j<count($questionarray[$i]["questions"]); $j++){
                    echo "<div>" .$questionarray[$i]["questions"][$j] . "</div>";
                    if($i==8 && ($j==1 || $j==2 || $j==3 || $j==4 || $j==5 || $j==6 || $j==7 )){
                        echo "<div> <input type='radio' name='Q$k' value='5' /> 没有 <input type='radio' name='Q$k' value='4' /> 很少 <input type='radio' name='Q$k' value='3' /> 有时 <input type='radio' name='Q$k' value='2' /> 经常 <input type='radio' name='Q$k' value='1' /> 总是</div>";                        
                    }else{
                        echo "<div> <input type='radio' name='Q$k' value='1' /> 没有 <input type='radio' name='Q$k' value='2' /> 很少 <input type='radio' name='Q$k' value='3' /> 有时 <input type='radio' name='Q$k' value='4' /> 经常 <input type='radio' name='Q$k' value='5' /> 总是 </div>";}
                    $k++;
                }
            }
            ?>
  
    <input type="submit" value="提交">  
   
<style>
  input[type=button], input[type=submit], input[type=reset]
   {background-color:cornflowerblue;  border: none;  color: white;  padding: 8px 200px;  text-decoration: none;  margin: 2px 1px;  cursor: pointer;  width: 100%;}
</style>
        </form>   
    </class=>   
    </div>
</body>
</html>